<% query=Query.find(:first, :conditions => ["id=?", query_id]) %>
<% if query!=nil %>
	<% sort_init(query.sort_criteria.empty? ? [['id', 'desc']] : query.sort_criteria) %>
	<% sort_update(query.sortable_columns) %>
	<% issues=query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version], :order => sort_clause) %>
	<h2><%= query.new_record? ? l(:label_issue_plural) : h(query.name) %> (<%= issues.size %>)</h2>
    <%= form_tag({}) do %>
	<table class="list issues">
	<thead>
		<tr>
	        <% query.columns.each do |column| %>
	          <%= content_tag('th', h(column.caption)) %>
	        <% end %>
	  	</tr>
	</thead>

	<% previous_group = false %>
	<tbody>
    <% issue_list(issues) do |issue, level| -%>
        <% if query.grouped? && (group = query.group_by_column.value(issue)) != previous_group %>
          <% reset_cycle %>
          <tr class="group open">
              <td colspan="<%= query.inline_columns.size + 2 %>">
              <span class="expander" onclick="toggleRowGroup(this);">&nbsp;</span>
              <%= group.blank? ? l(:label_none) : column_content(query.group_by_column, issue) %> <span class="count"><%= query.issue_count_by_group[group] %></span>
              <%= link_to_function("#{l(:button_collapse_all)}/#{l(:button_expand_all)}",
                                   "toggleAllRowGroups(this)", :class => 'toggle-all') %>
              </td>
          </tr>
          <% previous_group = group %>
        <% end %>
        <tr id="issue-<%= issue.id %>" class="hascontextmenu <%= cycle('odd', 'even') %> <%= issue.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
        <td class="checkbox hide-when-print" style="display:none;"><%= check_box_tag("ids[]", issue.id, false, :style => 'display:none;', :id => nil) %></td>
        <%= raw query.inline_columns.map {|column| "<td class=\"#{column.css_classes}\">#{column_content(column, issue)}</td>"}.join %>
        </tr>
	<% end %>
	</tbody>
	</table>
	<% end %>
<% else %>
	预设的自定义显示页面被人删除. Query has been removed.
<% end %>
